Skip to content

Fix TypeError crash in fetch_vulnerabilities when VulnerableCode is unreachable#2108

Closed
harshverma27 wants to merge 2 commits into
aboutcode-org:mainfrom
harshverma27:fix/fetch-vulnerabilities-none-crash
Closed

Fix TypeError crash in fetch_vulnerabilities when VulnerableCode is unreachable#2108
harshverma27 wants to merge 2 commits into
aboutcode-org:mainfrom
harshverma27:fix/fetch-vulnerabilities-none-crash

Conversation

@harshverma27
Copy link
Copy Markdown

bulk_search_by_purl() returns None when request_post() catches a network error or HTTP failure. The loop in fetch_vulnerabilities() iterated over the result directly, crashing with TypeError: 'NoneType' is not iterable.

Added a guard that skips the batch and logs a warning when response_data is falsy, so a VulnerableCode outage degrades gracefully instead of aborting the entire pipeline run.

Issues

Changes

scanpipe/pipes/vulnerablecode.py

Added a if not response_data guard inside the fetch_vulnerabilities loop. When bulk_search_by_purl() returns None (network failure, timeout, or HTTP error), the batch is now skipped with a warning logged to the pipeline run log rather than crashing with a TypeError.

scanpipe/tests/pipes/test_vulnerablecode.py

Added test_scanpipe_pipes_vulnerablecode_fetch_vulnerabilities_none_response which mocks bulk_search_by_purl to return None and asserts that the function completes without error, no vulnerabilities are stored, and the warning message appears in the log output.

Checklist

  • I have read the contributing guidelines
  • I have linked an existing issue above
  • I have added unit tests covering the new code
  • I have reviewed and understood every line of this PR

This fix was identified with assistance from Claude (Anthropic). The analysis, implementation, and testing were reviewed and understood by me before submission.

…nreachable

bulk_search_by_purl() returns None when request_post() catches a network error or HTTP failure. The loop in fetch_vulnerabilities() iterated over
the result directly, crashing with TypeError: 'NoneType' is not iterable.

Add a guard that skips the batch and logs a warning when response_data
is falsy, so a VulnerableCode outage degrades gracefully instead of
aborting the entire pipeline run.

Fixes aboutcode-org#2107

Signed-off-by: Harsh Verma <harshkardam246@gmail.com>
Signed-off-by: Harsh Verma <harshkardam246@gmail.com>
@harshverma27 harshverma27 force-pushed the fix/fetch-vulnerabilities-none-crash branch from ede5c1e to 76c32e9 Compare March 20, 2026 11:56
@AyanSinhaMahapatra
Copy link
Copy Markdown
Member

#2107 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fetch_vulnerabilities crashes with TypeError when VulnerableCode is unreachable

2 participants